<?php
include("food_conf.php");
?>
<?php
$shop_ID = $_GET["shop_ID"];
$display = "select * from food where shop_id='$shop_ID'";
$result = mysql_query($display,$conn) or die ("用户数据加载失败: ".mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>店家管理</title>
<script language="javascript"> 
    function information()
    {
		var food_ID = document.getElementById("food_ID").value;
		var food_name = document.getElementById("food_name").value;
		var food_value = document.getElementById("food_value").value;
		var food_state = document.getElementById("food_state").value;
	}
</script>

  <style text="text/css">
  td{
  font-size:28px;
  background-color:grey;
  width:280px;
  height:25px}
  body,td,th {
	font-size: 18px;
	color: #FC3;
}
body {
	background-color: #FFF;
	background-image: url(image/%E5%BA%97%E5%AE%B6&%E5%AD%A6%E7%94%9F%E5%90%8E%E5%8F%B0.jpg);
	background-repeat: no-repeat;
}
  a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
  </style>
</head>
<body>
<div align="center">
  <h3>欢迎用户<?php echo $shop_ID;?>进入食堂食物管理系统！</h3>
</div>
<div align="center">
<form method="post" action="" onSubmit="return information()"> 
<table bgcolor="#999999">
<tr align="center">
<td>食物编号</td>
<td>食物名</td>
<td>食物价格</td>
<td>食物状态</td>
</tr>
<tr align="center">
<td><input type="text" name="food_ID"></td>
<td><input type="text" name="food_name"></td>
<td><input type="text" name="food_value"></td>
<td><input type="text" name="food_state"></td>
</tr>
<input type="submit" name="submit" value="添加">
<input type="reset" name="reset" value="重写">
</table>
</form>
</div>
<?php
if ($num = mysql_num_rows($result))
{
	while($row = mysql_fetch_array($result,MYSQL_ASSOC))
	{
		if($row['food_ID']){}
	}
}
?>
</div>
</body>
<?php
$host = "127.0.0.1";
$user_name = "root";
$password = "000000";
/*if($_POST["submit"])
{
	获取信息
	$food_ID = $_POST['food_ID'];
	$food_name = $_POST['food_name'];
	$food_value = $_POST['food_value'];
	$food_state = $_POST['food_state'];

	$sql_f="select * from food where food_ID='$food_ID'";
	mysql_query($sql_f,$conn) or die (mysql_error());
	$sql_up = "update food set $food_name='$food_name',$food_value='$food_value',$food_state='$food_state' where  food_ID='$food_ID'";
	$result = mysql_query($sql_up,$conn) or die ("修改失败: ".mysql_error());
	echo "<script language=javascript>alert('修改成功！');window.location = 'shop_update.php'</script>";
}*/
if($_POST["submit"])
{
	$food_ID = $_POST['food_ID'];
	$food_name = $_POST['food_name'];
	$food_value = $_POST['food_value'];
	$food_state = $_POST['food_state'];

	$sql = "insert into food(food_ID,shop_ID,food_name,food_value,food_state) values('$food_ID','$shop_ID','$food_name','$food_value','$food_state')";
	mysql_query($sql,$conn) or die ("添加失败: ".mysql_error());
	echo "<script language=javascript>alert('添加成功！');window.location = 'shop_update.php'</script>";
}
?>
</html>
